//
//  PackageParser.h
//  Maze1
//
//  Created by Lin Tian on 9/19/11.
//  Copyright 2011 tina. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GameConfig.h"
#import "GameDefine.h"
#import "Net.h"
#import "LocalPlayer.h"
#import "HelloWorldLayer.h"
#import "Loading.h"
#import "RoomList.h"
#import "Room.h"
#import "Login.h"
#import "RoomInfo.h"


typedef enum {
    PlayerStateNone,
    PlayerStateLoggingIn,
    PlayerStateLoggingOut,
    PlayerStateInHall,
    PlayerStateCreatingRoom,
    PlayerStateEnteringRoom,
    PlayerStateInRoom,
    PlayerStateLeavingRoom,
    PlayerStateStartingGame,
    PlayerStateLoadingGame,
    PlayerStateLoadingGameComplete,
    PlayerStateInGame,
    PlayerStateGameEnd,
}msgType;

typedef enum {
    InGameTypePlayer,
    InGameTypeMap
}playerInGameMsgType;

@interface PackageParser : NSObject {
	bool isFirstMsg;
	Socket *_socket;
    LocalPlayer *player;
    msgType state;
	id scene;
    Address* from;
    Address* to;
    bool _posScene;
	
}

+(PackageParser*)sharedPackageParser;
//+(id)initPackageParser;
-(bool)updateLocalState;
-(bool)updateServerState;

-(bool)receivePlayerStateInHallWith:(char*)data;
-(bool)receivePlayerStateInRoomWith:(char*)data;
-(bool)receivePlayerStateLeavingRoomWith:(char *)data;
-(bool)receivePlayerStateLoadingGameWith:(char*)data;
-(bool)receivePlayerStateInGameWith:(char*)data;

-(bool)sendPlayerStateInGame;
-(bool)sendLoginRequest;
-(bool)sendLogoutRequest;
-(bool)sendPlayerStateInHall;
-(bool)sendCreateRoomRequest;
-(bool)sendLeaveRoomRequest;
-(bool)sendEnterRoomInfo;
-(bool)sendplayerStateInRoom;
-(bool)sendStartGameRequest;
-(bool)sendGameLoadingProgress;
-(bool)sendGameLoadingComplete;
-(bool)sendGameOverRequest;

@property (nonatomic) bool isFirstMsg;
@property (nonatomic, retain) Socket *socket;
@property (retain) LocalPlayer *player;
@property (nonatomic, retain) id scene;
@property (nonatomic) msgType state;
@property (nonatomic, retain) Address* from;
@property (nonatomic, retain) Address* to;
@end
